<template>
  <el-dropdown @command="handleCommand">
    <span class="el-dropdown-link">
      <svg-icon style="fill: white;font-size:20px" icon-class="language" />
    </span>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item command="zh" :disabled="$i18n.locale === 'zh'">中文</el-dropdown-item>
      <el-dropdown-item command="en" :disabled="$i18n.locale === 'en'">EN</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Cookies from 'js-cookie'
export default {
  methods: {
    handleCommand(command) {
      Cookies.set('language', command) // 存储语言类型到本地
      this.$i18n.locale = command // 设置当前语言类型给i18n插件
      this.$message.success('切换语言成功')
    }
  }
}
</script>

<style>

</style>
